<?php

class Ext_Url
{
    protected static $_instance = null;
    
    protected $_view;

    public static function getInstance()
    {
        if (null === self::$_instance) {
            self::$_instance = new self();
        }

        return self::$_instance;
    }
    
    public function __construct()
    {
        $bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
        $bootstrap->bootstrap('view');
        $this->_view = $bootstrap->getResource('view');
    }
    
    public function article($articleId)
    {
        return new Ext_Url_Article($articleId);
    }
    
    public function tag($tagId)
    {
        return new Ext_Url_Tag($tagId);
    }
    
    public function user($userId)
    {
        return new Ext_Url_User($userId);
    }

    public function auth()
    {
        return new Ext_Url_Auth();
    }

    public function tagDetail($tagRow)
    {
        $url = $this->_view->url(array('module'=>'default', 'controller'=>'tag', 'action'=>'article-list', 'tagId'=>$tagRow['id']), "default", true);
    
        return $url;
    }
    
    public function login()
    {
        $url = $this->_view->url(array('module'=>'account', 'controller'=>'login', 'action'=>'show-form'), "default", true);
    
        return $url;
    }

}